package studentManagent;

import java.util.Scanner;

public class studentManagment {
	public static void main(String[] args) {
		StudentManagent stumt = new StudentManagent();
		Scanner scan = new Scanner(System.in);
		while (true) {
			System.out.println("===欢迎使用学生管理系统===");
			System.out.println("1.添加新学生信息");
			System.out.println("2.学号删除学生信息");
			System.out.println("3.学号查询学生信息");
			System.out.println("4.班级查询学生信息");
			System.out.println("5.姓名查询学生信息");
			System.out.println("6.查询全部学生信息");
			System.out.println("7.查询全部不及格学生信息");
			System.out.println("8. 学生成绩排名");
			System.out.print("请选择所需服务：");
			int option = scan.nextInt();
			switch (option) {
			case 1:
				System.out.println("-----添加学生-----");
				System.out.print("请输入学生姓名:");
				String name = scan.next();
				System.out.print("请输入学生班级:");
				String className = scan.next();
				System.out.print("请输入学生学号:");
				int id = scan.nextInt();
				System.out.print("请输入学生成绩:");
				int score = scan.nextInt();
				Student student = new Student();
				student.name = name;
				student.className = className;
				student.id = id;
				student.score = score;
				System.out.println(stumt.add(student) ? "添加成功" : "添加失败");
				break;
			case 2:
				System.out.println("学号删除学生信息");
				System.out.print("请输入要删除学生学号");
				int stuID = scan.nextInt();
				System.out.println(stumt.remove(stuID) ? "删除成功" : "删除失败");
				break;
			case 3:
				System.out.println("===根据学号查询学生信息===");
				System.out.print("请输入要查询学生学号");
				int stuID2 = scan.nextInt();
				Student stuID3 = stumt.getById(stuID2);
				if (stuID3 != null) {
					System.out.println("姓名" + stuID3.name);
					System.out.println("班级" + stuID3.score);
					System.out.println("成绩" + stuID3.className);
				} else {
					System.out.println("查无此人");
				}
				break;
			case 4:
				System.out.println("===根据班级查询学生信息===");
				System.out.print("请输入要查询学生班级");
				String stuClassName = scan.next();
				stumt.getByClassName(stuClassName);
				break;
			case 5:
				System.out.println("===根据班级查询学生信息===");
				System.out.print("请输入要查询学生姓名");
				String stuName = scan.next();
				Student studentName = stumt.getByName(stuName);
				if (stuName != null) {
					System.out.println("姓名" + studentName.id);
					System.out.println("班级" + studentName.score);
					System.out.println("成绩" + studentName.className);
				} else {
					System.out.println("查无此人");
				}
				break;
			case 6:
				System.out.println("====查询所有学生====");
				System.out.println(stumt.listAll());
				break;
			case 7:
				System.out.println("===查询不及格学生===");

				Student notPass = stumt.getByScoreNotPass();
				System.out.println("班级" + notPass.className);
				System.out.println("学号" + notPass.id);
				System.out.println("名字" + notPass.name);
				System.out.println("成绩" + notPass.score);
				break;
			case 8:
				System.out.println("===成绩单===");
				String scoreList = stumt.sortByScore();
				System.out.println(scoreList);
			}
		}

	}
}
